package com.example.easyscript.utils.recognization.surfpro;

import org.opencv.core.MatOfDMatch;
import org.opencv.core.MatOfKeyPoint;
import org.opencv.features2d.DMatch;

import java.util.LinkedList;
import java.util.List;

public class ConsoleView implements MatchingView{

    @Override
    public int showView(MatOfDMatch matches,MatOfKeyPoint srcKP,MatOfKeyPoint dstKP) {

        double maxDist = Double.MIN_VALUE;
        double minDist = Double.MAX_VALUE;

        DMatch[] mats = matches.toArray();
        for(int i = 0;i < mats.length;i++){
            double dist = mats[i].distance;
            if (dist < minDist) {
                minDist = dist;
            }
            if (dist > maxDist) {
                maxDist = dist;
            }
        }
       List<DMatch> goodMatch = new LinkedList<>();

        for (int i = 0; i < mats.length; i++) {
            double dist = mats[i].distance;
            //dist < 3*minDist&&
            if( dist < 0.2f ){
                goodMatch.add(mats[i]);
            }
        }

        return goodMatch.size();
    }

    @Override
    public void setDstPic(String dstPath) {}

    @Override
    public void setSrcPic(String picPath) {}
}